package bp.App.Demo;

import bp.da.DataType;
import bp.en.EntityNoName;
import bp.en.EntityNoNameAttr;
import bp.en.Map;
import bp.en.UAC;
import bp.tools.SystemUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

/** 
 记事本
*/
public class ZhiBiaoFXFF extends EntityNoName
{
	///#region 基本属性
	public final String getMark()
	{
		return this.GetValStringByKey("Mark");
	}
	public final void setMark(String value)
	{
		this.SetValByKey("Mark",value);
	}
	public final String getVerEn()
	{
		return this.GetValStringByKey("VerEn");
	}
	public final void setVerEn(String value)
	{
		this.SetValByKey("VerEn", value);
	}
	public final int getVerSta()
	{
		return this.GetValIntByKey("VerSta");
	}
	public final void setVerSta(int value)
	{
		this.SetValByKey("VerSta", value);
	}


	/**
	 权限控制
	*/
	@Override
	public UAC getHisUAC()
	{
		UAC uac = new UAC();
		uac.IsUpdate = true;
		uac.IsInsert = true;
		return uac;
	}
	/**
	 计划
	*/
	public ZhiBiaoFXFF()
	{
	}
	public ZhiBiaoFXFF(String no) throws Exception
	{
		SetValByKey(EntityNoNameAttr.No,no);
		this.Retrieve();
	}
	/** 
	 重写基类方法
	*/
	@Override
	public Map getEnMap()
	{
		if (this.get_enMap() != null)
		{
			return this.get_enMap();
		}
		Map map = new Map("Demo_ZhiBiaoFXFF", "演示ZhiBiaoFXFF");

		map.AddGroupAttr("基本信息");
		map.AddTBStringPK("No", null, "编号", true, true, 4, 4, 80); //如果设置自动编号字段必须是只读的.
		map.AddTBString("Mark", null, "助记码", true, true, 0, 4, 50);
		map.AddTBString("Name", null, "分析方法及依据", true, true, 0, 150, 100);

		map.AddTBString("EnVer", "1", "版本号", true, true, 0, 4, 50);
		map.AddTBInt("EnSta", 0, "版本状态", true, false);

		map.AddTBString("ZhiBiaoNo", null, "项目编号", true, true, 0, 4, 50);
		map.AddTBString("ZhiBiaoName", null, "项目名称", true, true, 0, 150, 100);

		map.AddGroupAttr("采样信息");
		map.AddTBFloat("FeeCaiYang", 0, "采样费", true, true);
		map.AddBoolean("IsDDCY", false, "单独采样", true, true);
		map.AddTBInt("YB_YXQDays", 15, "样本保存有效期天", true, false);
		map.AddTBInt("YB_YXQHours", 0, "小时", true, false);
		map.AddTBString("GDJBH", null, "固定剂编号", true, false, 0, 150, 100);

		map.AddGroupAttr("分析信息");
		map.AddTBFloat("JCX_Up", 0, "检出上限", true, false);
		map.AddTBFloat("JCX_Down", 0, "检出下限", true, false);

		map.AddTBFloat("FeeOfFenXi", 0, "分析费", true, false);
		map.AddTBFloat("FeeOfQCL", 0, "前处理费", true, false);
		map.AddTBFloat("FeeOfKaiJi", 0, "开机费", true, false);

		map.AddBoolean("IsHaveZKY", false, "有质控样", true, true);
		map.AddBoolean("IsHaveBlankYB", false, "有空白样本", true, true);
		map.AddBoolean("IsHaveBZQX", false, "有标准曲线模版", true, true);
		map.AddTBInt("HYDays", 2, "分析需要的天数", true, false);
		map.AddTBString("JLDW", "mg/l", "计量单位", true, false, 0, 50, 50);
		map.AddTBFloat("ValOfJC", 0, "检出限", true, false);

		map.AddGroupAttr("计量认证信息");
		map.AddTBDate("YXQFrom", null, "计量认证有效期从", true, false);
		map.AddTBDate("YXQTo", null, "到", true, false);
		this.set_enMap(map);
		return this.get_enMap();
	}

	@Override
	protected boolean beforeInsert() throws Exception {
		SetValByKey("RDT", DataType.getCurrentDateTime());
		try
		{
			String jsonString = SystemUtil.GetCityByIp("");
			// 将 JSON 字符串转换为对象
			JSONObject json= JSON.parseObject(jsonString);
			SetValByKey("IPAddr", json.getString("ip"));
			SetValByKey("Locatinon", json.getString("pro") + " " + json.getString("city"));
			SetValByKey("Brower", SystemUtil.GetBrowser());
			SetValByKey("OS", SystemUtil.GetOperatingSystem());
		}
		catch (RuntimeException e)
		{

		}

		return super.beforeInsert();
	}

	///#region 基本属性
	public final String getLoginData()
	{
		return GetValStringByKey("LoginData");
	}
	public final void setLoginData(String value)
	{
		SetValByKey("LoginData", value);
	}
	//#endregion
}
